using IQIGame.Onigao.Framework;
using System;

namespace IQIGame.Onigao.Game
{
    public interface ISession
    {
        /// <summary>
        /// 获取网络线程Executor
        /// </summary>
        /// <returns></returns>
        IExecutor GetExecutor();

        bool SendPack(SendPackage pack);

        bool Send(byte[] data) { return false; }

        /// <summary>
        /// 关闭session
        /// </summary>
        void Close(bool active = false);
        /// <summary>
        /// 断开session
        /// </summary>
        void Disconnect();

    }

    public interface IExecutor
    {
        void Execute(Action action);
    }

    /// <summary>
    /// 只是为了和服务器保持结构一致
    /// 直接运行action
    /// </summary>
    public class DefaultSessionExecutor : Singleton<DefaultSessionExecutor>, IExecutor
    {
        private DefaultSessionExecutor() { }
        public void Execute(Action action)
        {
            action();
        }
    }
}
